package com.webSite.demo.cy.downBook;

import java.io.File;

import cn.hutool.core.util.RuntimeUtil;

public class ChmUtil {
	
	public static void main(String[] args) {
		downJSAndPack("从零开始竞选冬木市长⊙但慰青帝⊙连载至225",225,"C:\\Users\\fengzihao\\Desktop\\12121");
		
	}
	
	/**
	 * 
	* @Title: downJSAndPack  
	* @Description: TODO()  
	* @param @param bookName 书名
	* @param @param chatNum 章节数量
	* @param @param jsPath    参数  JS的路径
	* @return void    返回类型  
	* @throws
	 */
	private static void downJSAndPack(String bookName,int chatNum,String jsPath) {
		for(int i=1;i<=chatNum;i++) {
			RuntimeUtil.execForStr("hh.exe mk:@MSITStore:C:\\Users\\fengzihao\\Desktop\\"+bookName+".chm::/txt/"+getChaNum(i)+".js");
		
		}
		JsTest.makeBookAndDelete(new File(jsPath), bookName);
	}



	/**
	 * id生成器
	* @Title: getChaNum  
	* @Description: TODO()  
	* @param @param num
	* @param @return    参数  
	* @return String    返回类型  
	* @throws
	 */
	private static String getChaNum(int num) {
		StringBuilder builder = new StringBuilder("1310000");
		String nums = num+"";
		if(nums.length()==1) {
			return builder.append("000").append(nums).toString();
		}else if(nums.length()==2){
			return builder.append("00").append(nums).toString();
		}else if(nums.length()==3){
			return builder.append("0").append(nums).toString();
		}else {
			return builder.append(nums).toString();
		}
	}

	
}
